package com.qdlc.p2p.biz.protocol;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

/**
 * 协议帮助类
 *  
 * @author linya 2016-01-28
 */
@Service
public class ProtocolHelper implements ApplicationContextAware{
	
	private static ApplicationContext context;
	
	/**
	 * 根据key获取，逻辑bean
	 * @param key
	 * @return
	 */
	public static <T extends ProtocolBean> T doProtocol(Class<T> protocolBeanClass) {
		T protocolBean = context.getBean(protocolBeanClass);
		return protocolBean;
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		context = applicationContext;
	}

}
